package com.situ.vivamarket.controller.sys;

import com.situ.vivamarket.model.Order;
import com.situ.vivamarket.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
@RequestMapping("/vm/sys/order")
public class OrderController {
    private OrderService orderService;
    @Autowired
    public void setOrderService(OrderService orderService) {
        this.orderService = orderService;
    }

    @GetMapping("/list")
    public String list() {
        return "sys/order/list";
    }
    @GetMapping("/edit")
    public String edit(Integer id, Map<String, Object> map) {
        if (id == null) {
            map.put("error","修改的ID为空");
            return "sys/order/edit";
        }
        Order order = this.orderService.findById(id);
        if (order == null) {
            map.put("error","要修改的订单不存在");
        }else{
            map.put("order",order);
        }
        return "sys/order/edit";

    }
}
